package com.finance.web.service.impl;

import java.util.List;
import com.finance.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.finance.web.mapper.FmAccountMapper;
import com.finance.web.domain.FmAccount;
import com.finance.web.service.IFmAccountService;
import com.finance.common.core.text.Convert;

/**
 * 账户Service业务层处理
 *
 * @author lisen
 * @date 2021-11-11
 */
@Service
public class FmAccountServiceImpl implements IFmAccountService
{
    @Autowired
    private FmAccountMapper fmAccountMapper;

    /**
     * 查询账户
     *
     * @param id 账户主键
     * @return 账户
     */
    @Override
    public FmAccount selectFmAccountById(Long id)
    {
        return fmAccountMapper.selectFmAccountById(id);
    }

    /**
     * 查询账户列表
     *
     * @param fmAccount 账户
     * @return 账户
     */
    @Override
    public List<FmAccount> selectFmAccountList(FmAccount fmAccount)
    {
        return fmAccountMapper.selectFmAccountList(fmAccount);
    }

    /**
     * 新增账户
     *
     * @param fmAccount 账户
     * @return 结果
     */
    @Override
    public int insertFmAccount(FmAccount fmAccount)
    {
        fmAccount.setVersion(0L);
        fmAccount.setCreateTime(DateUtils.getNowDate());
        return fmAccountMapper.insertFmAccount(fmAccount);
    }

    /**
     * 修改账户
     *
     * @param fmAccount 账户
     * @return 结果
     */
    @Override
    public int updateFmAccount(FmAccount fmAccount)
    {
        fmAccount.setModifyTime(DateUtils.getNowDate());
        return fmAccountMapper.updateFmAccount(fmAccount);
    }

    /**
     * 批量删除账户
     *
     * @param ids 需要删除的账户主键
     * @return 结果
     */
    @Override
    public int deleteFmAccountByIds(String ids)
    {
        return fmAccountMapper.deleteFmAccountByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除账户信息
     *
     * @param id 账户主键
     * @return 结果
     */
    @Override
    public int deleteFmAccountById(Long id)
    {
        return fmAccountMapper.deleteFmAccountById(id);
    }
}
